package com.itsitio.registeradmin.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "sucursales")
public class Branch {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "idx")
	private Integer id;
	
	//Nombre de la sucursal	
	@Column(name = "nombre")
	private String name;
	
	//Central
	@Column(name = "central")
	private Integer central;
	
	//Direccion
	@Column(name = "direccion")
	private String address;
	
	//Localidad
	@Column(name = "localidad")
	private String city;
	
	//Codigo Postal
	@Column(name = "cp")
	private String zipCode;

	//Telefono
	@Column(name = "telefono")
	private String phone;

	//Fax
	@Column(name = "fax")
	private String fax;
	
	 //@ManyToOne(fetch = FetchType.EAGER)
	 //private Country country;
	
	// Provincia -- sucursal_idxprovincia
	@ManyToOne(cascade = CascadeType.MERGE)
	@JoinColumn(name="idxprovincia")
	private Province province;	
	
	@ManyToOne( cascade = {CascadeType.ALL} )
    @JoinTable(name="empresas_relacion_sucursales", joinColumns = @JoinColumn(name="idxsucursal"), inverseJoinColumns = @JoinColumn(name="idxEmpresa") )
	private Company company;
	
	@OneToMany(mappedBy="branch")
	private List<User> users;		

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getCentral() {
		return central;
	}

	public void setCentral(Integer central) {
		this.central = central;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public Province getProvince() {
		return province;
	}

	public void setProvince(Province province) {
		this.province = province;
	}
	

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}	
	
}
